//
//  CommonStwxItemCell.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/10/23.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "CommonStwxItemCell.h"

@interface CommonStwxItemCell()

/// viewModle
@property (nonatomic, readwrite, strong) CommonStwxItemViewModel *viewModel;

/// IBOutlet
@property (weak, nonatomic) IBOutlet UILabel* contentLabel;
@property (weak, nonatomic) IBOutlet UILabel* nameLabel;
@property (weak, nonatomic) IBOutlet UILabel* goodNumLabel;
@property (weak, nonatomic) IBOutlet UILabel* commentNumLabel;
@property (weak, nonatomic) IBOutlet UILabel* readNumLabel;
@property (weak, nonatomic) IBOutlet UILabel* readLastDateLabel;
@property (weak, nonatomic) IBOutlet UIImageView* avatarImgView;

@end

@implementation CommonStwxItemCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

#pragma mark - bind data
- (void)bindViewModel:(CommonStwxItemViewModel *)viewModel
{
    self.viewModel = viewModel;
    
    self.contentLabel.text = self.viewModel.content;
    self.nameLabel.text = self.viewModel.name;
    self.goodNumLabel.text = self.viewModel.goodNum;
    self.commentNumLabel.text = self.viewModel.commentNum;
    self.readLastDateLabel.text = self.viewModel.readLastDate;
    self.readNumLabel.text = self.viewModel.readNum;

    [self.avatarImgView yy_setImageWithURL:[NSURL URLWithString:self.viewModel.imgurl] placeholder:MHImageNamed(@"placeholderLogo")];

    [[[self rac_signalForSelector:@selector(layoutSubviews)] takeUntil:[self rac_prepareForReuseSignal]] subscribeNext:^(id x)
    {
        self.avatarImgView.layer.cornerRadius = self.avatarImgView.frame.size.width/2.0f;
        self.avatarImgView.layer.masksToBounds = YES;
    }];
}

@end
